<?php
//including header.php 
include '../../include/header.php';
//including page.php (It is a class which contain functions)
include '../../libraries/page.php';
//created object for page.php
$page = new page();
session_start();
$userid = $_SESSION['userid'];

//To get current date and time
date_default_timezone_set('Asia/Calcutta');
$date1 = date("d-m-Y H:i:s");

// checking the session
if (!$_SESSION['username']) {
    header("location:../user/login.php");
}
if ($_GET['q'] == 'logout') {
    $page->user_logout();
    header("location:../user/login.php");
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {

    $result = $page->mysql_insert_array("invoicedetails", $_POST, "submit");
    if ($result) {
        $msg = $message[1];
    } else {
        $msg = $message[0];
    }
}
?>

<!--------------------------------------------------content----------------------------------->

<!-------------------------------------Navbar---------------------------------->
<?
$stock_register = 'active';
include '../../include/navbar.php';
?>

   <div class="bread_crumb" style="margin-left: 2%">
       &laquo;  <a href="stock_register">Back</a>
  </div>

<!----------------------------------Display the result message of Addition--------------------->
<div  align="center"><? echo $msg; ?></div>


<!---------------------------------form------------------------------------------------>
<form method="POST"  action="">
    <div class="maindiv">
        <h3 style="color:#777;text-align: center">Add Stock</h3>
        <div class="leftdiv">
            <label>Invoice ID</label>
            <input class="input-xlarge" id="focusedInput" type="text" name ="invoiceid" placeholder="Enter Invoice Id..."  required>
        </div>
        <div class="middiv"></div>
        <div class="rightdiv">
            <label>product</label>
            <select name="productid" style="width:280px" required>
                <option></option>
                <?
                $products = mysql_query("select * from products");
                $id = 0;
                while ($products_data = mysql_fetch_array($products)) {
                ?>
                <option value="<?= $products_data['productid']; ?>"><?= $products_data['name']; ?></option>
                <?
                }
                ?>
            </select>
        </div>
        <div class="leftdiv">
            <label>Batch No</label>
            <input class="input-xlarge" id="focusedInput" type="text" name ="batchno" placeholder="Enter batchno..." >
        </div>
        <div class="middiv"></div>
        <div class="rightdiv">
            <label>Expiry Date</label>
            <input class="input-xlarge" id="focusedInput" type="datetime-local"  name ="expirydate" >
        </div>
        <div class="leftdiv">
            <label>Qty</label>
            <input class="input-xlarge" id="focusedInput" type="number" name ="qty" placeholder="Only Integer value ..."   >
        </div>
        <div class="middiv"></div>
        <div class="rightdiv">
            <label>Free</label>
            <input class="input-xlarge" id="focusedInput" type="number" name ="free" placeholder="Only Integer value... "   >
        </div>
        <div class="leftdiv">
            <label>Rate</label>
            <input class="input-xlarge" id="focusedInput" type="text" name ="rate" placeholder="Enter rate..."  >
        </div>
        <div class="middiv"></div>
        <div class="rightdiv">
            <label>MRP</label>
            <input class="input-xlarge" id="focusedInput" type="text" name ="mrp" placeholder="Enter MRP..."  >

        </div>
        <div class="leftdiv">
            <label>Tax</label>
            <input class="input-xlarge" id="focusedInput" type="text" name ="tax" placeholder="Enter Tax..."  >
        </div>
        <div class="middiv"></div>
        <div class="rightdiv">
            <label>Total</label>
            <input class="input-xlarge" id="focusedInput" type="text" name ="total" placeholder="Enter Total..."  >

        </div>
        <div class="leftdiv">
            <label>Sold</label>
            <input class="input-xlarge" id="focusedInput" type="text" name ="sold" >
        </div>
        <div class="middiv"></div>
        <div class="rightdiv">
            <label>Bcode</label>
            <input class="input-xlarge" id="focusedInput" type="text" name ="bcode" placeholder="Enter barcode..."  >

        </div>
        <div class="fulldiv">
            <div class="btn1"><button class="btn btn-inverse"  type="submit" name="submit" >Add stock</button></div>
        </div>
    </div>

</form>
</div>

<?php
//including footer.php
include '../../include/footer.php';
?>
